package com.oocl.euc.core.attachment.controller;

import com.oocl.euc.core.maintenance.controller.UsersController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

@RunWith(SpringRunner.class)
@TestPropertySource(locations = {"classpath:application-test.yml"})
@SpringBootTest
public class UsersControllerIT {
    @Autowired
    private WebApplicationContext context;
    private MockMvc mvc;

    @Autowired
    UsersController usersController;

    @Before
    public void setUp() throws Exception {
        mvc = MockMvcBuilders.webAppContextSetup(context).build();//建议使用这种
    }

    @Test
    public void given_get_temp_user_list_url_expect_get_all_temp_users() throws Exception {
        mvc.perform(MockMvcRequestBuilders.get("/rest/users/getTempUser")
                .contentType(MediaType.APPLICATION_JSON_UTF8)
                .accept(MediaType.APPLICATION_JSON))
                .andExpect(MockMvcResultMatchers.status().isOk());

    }
}